package cn.lyl.basic.util;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * 工具类：封装增删改的返回结果
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
public class AjaxResult {
    //响应给前端用户判断
    private Boolean success = true;
    //响应给前端字符串的信息
    private String msg = "操作成功";
    //响应给前端任意类型的数据 - fastDfs
    private Object obj;

    public String getMsg() {
        return msg;
    }

    public AjaxResult setMsg(String msg) {
        this.msg = msg;
        return this;
    }

    public AjaxResult setResultObj(Object obj){
        this.obj = obj;
        return this;
    }

    //链式语法改造
    public static  AjaxResult me(){
        return new AjaxResult();
    }

    public boolean getSuccess(){return success;}
    //链式语法改造
    public AjaxResult setSuccess(Boolean success){
        this.success=success;
        return this;
    }

    public AjaxResult(Boolean success, String msg) {
        this.success = success;
        this.msg = msg;
    }
}
